<template>
	<div class="ml-bg-register-001">
		<div v-on:click="goDownload" class="ml-icon-register-012"></div>
		<div v-show="showPop" class="pop" id="register-pop"></div>
		<div v-show="showPop" class="pop-box" id="pop-box">
			<div class="ml-bg-register-007"></div>
			<p>恭喜您注册成功！快去领取专属加息券！</p>
			<p  v-on:click="goDownload" class="btn">立即下载盈鱼理财</p>
		</div>
		<div class="box"></div>
		<ul class="ml-register-ul1">
			<li>
				<span class="ml-icon-register-007"></span>
				<p>国企控股<br/>银行存管</p>
			</li>
			<li>
				<span class="ml-icon-register-008"></span>
				<p>Icp许可证<br />沪ICP备15048049号-1</p>
			</li>
			<li>
				<span class="ml-icon-register-009"></span>
				<p>国有企业<br />全额投资</p>
			</li>
			<li>
				<span class="ml-icon-register-010"></span>
				<p>由宝付提供第三 方安全支付通道</p>
			</li>
		</ul>
		<div class=" input-box">
			<p><input class="user-input" v-model="tel" type="number" placeholder="请输入手机号"/></p>
			<p>
				<input class="code-input" v-model="imgCode" type="text" placeholder="请输入"/>
				<img v-on:click="getImg" :src="imgSrc" alt="" />
			</p>
			<p>
				<input class="code-input" v-model="code" type="number" placeholder="请输入验证码"/>
				<span v-on:click="getMsg($event)">{{msg}}&nbsp;{{msgS}}</span>
			</p>
			<div v-on:click="register" class="btn">立即注册赚钱</div>
		</div>
		<div class="pro-box">
			<ul class="box-title">
				<li>
					<span class="ml-icon-register-011"></span>
				</li>
				<li>
					<p>盈鱼新手专享</p>
					<p>新手福利 稳健收益</p>
				</li>
				<li>
					<span class="ml-icon-register-011"></span>
				</li>
			</ul>
			<div class="ml-bg-register-004">
				<p class="title">定期</p>
				<p class="content">为用户体验而隆重推出的一款金融产品。</p>
				<ul>
					<li>
						<p>历史年化收益率</p>
						<p>12+1<span>%</span></p>
					</li>
					<li>
						<p>投资期限</p>
						<p>15天</p>
					</li>
					<li>
						<p>最高投资金额</p>
						<p>5万</p>
					</li>
				</ul>
			</div>
		</div>
		<div class="pro-box">
			<ul class="box-title">
				<li>
					<span class="ml-icon-register-011"></span>
				</li>
				<li>
					<p>铜鱼宝</p>
					<p>安心资产 稳健收益</p>
				</li>
				<li>
					<span class="ml-icon-register-011"></span>
				</li>
			</ul>
			<div class="ml-bg-register-003">
				<p class="title">定期</p>
				<p class="content">铜鱼宝是盈鱼理财平台推出的一款全新的互联网理财产品，是资产端构筑于以核心企业为依托的贸易体系的新产品。资产端以整个供应体系为对象，将资金投向供应链的各需求环节，加快商品流通，提升企业资金周转效率。</p>
				<ul>
					<li>
						<p>历史年化收益率</p>
						<p>11+1<span>%</span></p>
					</li>
					<li>
						<p>投资期限</p>
						<p>30天</p>
					</li>
				</ul>
			</div>
		</div>
		<div class="pro-box">
			<ul class="box-title">
				<li>
					<span class="ml-icon-register-011"></span>
				</li>
				<li>
					<p>银鱼宝</p>
					<p>安心资产 稳健收益</p>
				</li>
				<li>
					<span class="ml-icon-register-011"></span>
				</li>
			</ul>
			<div class="ml-bg-register-003">
				<p class="title">定期</p>
				<p class="content">银鱼宝是盈鱼理财平台推出的一款全新的互联网理财产品，是资产端构筑于以核心企业为依托的贸易体系的新产品。资产端以整个供应体系为对象，将资金投向供应链的各需求环节，加快商品流通，提升企业资金周转效率。</p>
				<ul>
					<li>
						<p>历史年化收益率</p>
						<p>12+1<span>%</span></p>
					</li>
					<li>
						<p>投资期限</p>
						<p>60天</p>
					</li>
				</ul>
			</div>
		</div>
		<div class="pro-box">
			<ul class="box-title">
				<li>
					<span class="ml-icon-register-011"></span>
				</li>
				<li>
					<p>活鱼宝</p>
					<p>安心资产 随存随取</p>
				</li>
				<li>
					<span class="ml-icon-register-011"></span>
				</li>
			</ul>
			<div class="ml-bg-register-002">
				<p class="title">活期</p>
				<p class="content">活鱼宝是盈鱼理财平台推出的一款活期产品，投资门槛低（最低100元起投），随存随取，安全理财。资产投向收益权转让，银行承兑汇票等金融业务，安全可靠。</p>
				<ul>
					<li>
						<p>历史年化收益率</p>
						<p>7+1<span>%</span></p>
					</li>
					<li>
						<p>投资期限</p>
						<p>随存随取</p>
					</li>
				</ul>
			</div>
		</div>
		<p class="bottom">上海精舍华林文化投资有限公司 沪ICP备15048049号-1<br/>市场有风险 投资需谨慎</p>
		<div class="msg" v-show="showMsg" style="text-align:center;position:fixed;z-index: 999999999;width: 100%;"><div style="padding: 10px; border-radius: 4px;color:#fff; background:#5F6161; display:inline-block; " class="ml-message">{{alertMsg}}</div></div>
	</div>
</template>

<script>
import md5 from "../../config/md5.js"
import request from "../../config/request.js"
import judgeSystem from "../../config/judgeSystem.js"
export default {
	data() {
		return {
			tel:'',
			code:'',
			num:'',
			confirm:true,
			msg:'获取验证码',
			msgS:null,
			alertMsg:null,
			showMsg:false,
			system:null,
			channel:null,
			downloadUrl:null,
			showPop:false,
			imgCode:'',
			imgSrc:null
		}
	},
	created() {
        (function(root) {
            root._tt_config = true;
            //
            var ta = document.createElement('script'); ta.type = 'text/javascript'; ta.async = true;
            ta.src = document.location.protocol + '//' + 's1.pstatp.com/bytecom/resource/track_log/src/toutiao-track-log.js';
            ta.onerror = function () {
                var request = new XMLHttpRequest();
                var web_url = window.encodeURIComponent(window.location.href);
                var js_url  = ta.src;
                var url = '//ad.toutiao.com/link_monitor/cdn_failed?web_url=' + web_url + '&js_url=' + js_url + '&convert_id=93384419857';
                request.open('GET', url, true);
                request.send(null);
            }
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ta, s);
            //今日头条ff
            var ta1 = document.createElement('script'); ta.type = 'text/javascript'; ta.async = true;
            ta1.src = document.location.protocol + '//' + 's1.pstatp.com/bytecom/resource/track_log/src/toutiao-track-log.js';
            ta1.onerror = function () {
                var request = new XMLHttpRequest();
                var web_url = window.encodeURIComponent(window.location.href);
                var js_url  = ta.src;
                var url = '//ad.toutiao.com/link_monitor/cdn_failed?web_url=' + web_url + '&js_url=' + js_url + '&convert_id=93645955728';
                request.open('GET', url, true);
                request.send(null);
            }
            var s1 = document.getElementsByTagName('script')[0]; s1.parentNode.insertBefore(ta1, s1);
            //硬核
            var ta2 = document.createElement('script'); ta2.type = 'text/javascript'; ta2.async = true;
            ta2.src = document.location.protocol + '//' + 's1.pstatp.com/bytecom/resource/track_log/src/toutiao-track-log.js';
            ta2.onerror = function () {
                var request = new XMLHttpRequest();
                var web_url = window.encodeURIComponent(window.location.href);
                var js_url  = ta2.src;
                var url = '//ad.toutiao.com/link_monitor/cdn_failed?web_url=' + web_url + '&js_url=' + js_url + '&convert_id=93645923479';
                request.open('GET', url, true);
                request.send(null);
            }
            var s2 = document.getElementsByTagName('script')[0]; s2.parentNode.insertBefore(ta2, s2);
        })(window);
	},
	mounted(){
		var h = window.innerHeight;
		this.$(".ml-bg-register-001 .msg").css("bottom",h*0.2);
		var detect = judgeSystem.detect(navigator.userAgent);
		var self = this;
		self.getImg();
		var popBox= document.getElementById("pop-box");
		popBox.addEventListener("touchmove", function(e) {
			e.preventDefault();
		}, false);
		var registerPop= document.getElementById("register-pop");
		registerPop.addEventListener("touchmove", function(e) {
			e.preventDefault();
		}, false);
		if(detect.os.ios){
			self.system = 'ios';
			self.channel = self.$route.params.channel;
		}else{
			self.system = 'android';
			self.channel = self.$route.params.channel;
		}
		self.$.ajax({ 
			url:'/fish-backend/apis/app/getDownloadPath',   //提交的url
			type:'GET',
			beforeSend:function(xhr){		  	        		
				xhr.setRequestHeader('appidentifier',self.system);	
				xhr.setRequestHeader('source','web');
				xhr.setRequestHeader('channel',self.channel);	
		    },
		    success:function(res){
				self.$data.downloadUrl = res.data.downloadPath;
			}
		});	
	},
	updated(){

	},
	methods: {
		goDownload(){	
			var self=this;
			location.href = this.$data.downloadUrl;
		},
		clickBox(confirm){
			var self=this;
			this.confirm=!confirm;
		},
		getImg(){
			var self=this;
			self.imgSrc="/fish-backend/apis/ope/captcha.jpg?date="+new Date().valueOf();
		},
		register(event){
			var self=this;
			if(self.tel.length!=11){
				self.$data.showMsg=true;
				self.$data.alertMsg='请输入正确的手机号';
				setTimeout(function(){
					self.$data.showMsg=false;
				},2000);
				return;
			}
//			if(!self.confirm){
//				self.$data.showMsg=true;
//				self.$data.alertMsg='请阅读并同意用户协议';
//				setTimeout(function(){
//					self.$data.showMsg=false;
//				},2000);
//			}else{
			var _date=new Date().getTime();
			var sign = "_date="+_date+"&code="+self.$data.code+"&phone="+self.$data.tel+"&op123$#@!0987&*(";
			sign = md5.md5(sign).toLocaleLowerCase();
			self.$.ajax({
				url:'/fish-backend/apis/ope/simpleRegister',
				type:'POST',
				beforeSend:function(xhr){		 
					xhr.setRequestHeader('appidentifier',self.system);
					xhr.setRequestHeader('source','web');
					xhr.setRequestHeader('channel',self.channel);
				},
				data:{	
					'_date':_date,
					'code':self.code,
					'phone':self.tel,			 	
					'sign':sign
				},
				success:function(data){
					self.$data.showMsg=true;
					self.$data.alertMsg=data.msg;
					if(data.code==0){
						self.showPop=true;	
						_taq.push({convert_id:"93384419857", event_type:"form"});
						_taq.push({convert_id:"93645955728", event_type:"form"});
						_taq.push({convert_id:"93645923479", event_type:"form"});
					}
				}
			});
		},
		getMsg(event){
			//this.getImg();
			var self=this;
			if(self.tel.length!=11){
				self.$data.showMsg=true;
				self.$data.alertMsg='请输入正确的手机号';
				setTimeout(function(){
					self.$data.showMsg=false;
				},2000);
				return;
			}
			if(self.imgCode==""){
				self.$data.showMsg=true;
				self.$data.alertMsg="请输入图形验证码";
				setTimeout(function(){
					self.$data.showMsg=false;
				},2000);				
				return;
			}
			request.getCheckUser({'phone':self.tel},function(res){
				if(!res.data){
					var _date=new Date().getTime();
					var sign = "_date="+_date+"&imgCode="+self.$data.imgCode+"&phone="+self.$data.tel+"&op123$#@!0987&*(";
					sign = md5.md5(sign).toLocaleLowerCase();
					var param={	
						'_date':_date,
						'imgCode':self.imgCode,
						'phone':self.tel,			 	
						'sign':sign
					}
//					request.getPhoneMsg(param,function(data){
//						self.$data.msg=60;
//						console.log(self.$(event.target).css("pointer-events"));
//						self.$(event.target).css("pointer-events",'none');
//						var timer = setInterval(function(){
//							self.$data.msg--;
//							if(self.$data.msg==0){
//								clearInterval(timer);
//								self.$data.msg="获取验证码";
//								self.$(event.target).css("pointer-events",'auto');
//							}
//						},1000);
//					});
					self.$.ajax({
						url:'/fish-backend/apis/ope/sms/send',
						type:'POST',
						beforeSend:function(xhr){		 
							xhr.setRequestHeader('appidentifier','ios');
							xhr.setRequestHeader('source','web');
							xhr.setRequestHeader('channel','yingyu686');
						 },
						 data:{	
							'_date':_date,
							'imgCode':self.imgCode,
							'phone':self.tel,			 	
							'sign':sign
						 },
						 success:function(data){
						 	if(data.msg!="请求成功"){
						 		self.$data.showMsg=true;
						 		self.$data.alertMsg=data.msg;
						 		if(data.code==20011){
						 			self.getImg();
						 		}
						 		setTimeout(function(){
							 		self.$data.showMsg=false;
							 	},2000);
						 	}else{
								self.$data.msg=60;
								self.$data.msgS="S";
								self.$(event.target).css("pointer-events",'none');
								var timer = setInterval(function(){
									self.$data.msg--;
									if(self.$data.msg==0){
										clearInterval(timer);
										self.$data.msg="获取验证码";
										self.$(event.target).css("pointer-events",'auto');
									}
									if(self.$data.msg!="获取验证码"){
										self.$data.msgS="S";
									}else{
										self.$data.msgS="";
									}
								},1000);						 		
						 	}
						 }
					});
				}else{
					self.$data.showMsg=true;
					self.$data.alertMsg="该手机号已被注册";
					setTimeout(function(){
						self.$data.showMsg=false;
					},2000);
				}
			});
		}
	}
}		
</script>

<style lang="scss">
.ml-bg-register-001{
	position: relative;
	.bottom{
		color:#fff;
		font-size:18px;
		text-align: center;
		padding-top:70px;
		line-height:40px;
	}
	.pop{
		position:fixed;
		width:100%;
		height:100%;
		background:#909090;
		top: 0;
	    opacity: 0.7;
	    z-index:10; 
	}
	.pop-box{
		position:fixed;
		z-index:200;
		width:90%;
		left:5%;
		top:30%;
		border-radius: 35px;
		text-align: center;
		background: #fff;
		padding:30px 0;
		p{
			font-size:29px;
			font-family:FZLTHJW--GB1-0;
			color:rgba(0,0,0,1);
			width:90%;
			margin:20px auto;
		}
		p.btn{
			font-size:28px;
			font-family:FZLTHJW--GB1-0;
			color:rgba(255,236,236,1);
			background:rgba(42,89,220,1);
			border-radius: 30px ;
			width:50%;
			margin:20px auto;
			height:65px;
			line-height: 65px;
		}
	}
	.ml-register-ul1{
		overflow: hidden;
		li{
			float:left;
			width:25%;
			text-align: center;
			p{
				color:#FFFFFF;
				text-align: center;
				margin:0 auto;
				width:90%;
				line-height:30px;
			}
		}
	}
	.box{
		height:800px;
	}
	.input-box{
		padding:20px 0 40px;
		margin-top:40px;
		background:#F3EAFF;
		width:90%;
		margin:40px auto 0;
		border-radius: 16px;
		div.btn{
			font-size:36px;
			height:72px;
			width:80%;
			margin:0 auto;
			background:rgba(252,216,1,1);
			border-radius: 10px ;
			text-align: center;
			font-family:FZLTHJW--GB1-0;
			color:rgba(6,6,6,1);
			line-height:72px;
		}
		p{
			width:80%;
			border-radius: 16px;
			margin:30px auto;
			overflow: hidden;
			input{
				border:none;
				padding:0 30px;
				height:70px;
				box-sizing: border-box;
				font-family: PingFang-SC-Regular;
				font-size: 30px;
				color: #666666;
				letter-spacing: 4px;
				border:0;
				background: transparent;
			}
			.user-input{					
				background: #FFFFFF;

				width:100%;
				margin:0 auto;				
			}
			.code-input{
				width:55%;
				background: #FFFFFF;				
				margin:0 auto;
				border-radius: 16px;
			}
			span{
				display: inline-block;
				height:70px;
				font-family: PingFang-SC-Regular;
				font-size: 34px;
				color: #fff;
				box-sizing: border-box;
				padding:10px 0 10px 0px;
				position: relative;
				padding-top:18px;
				top:5px;
				width:40%;
				margin:0 auto;
				margin-left:3%;
				text-align: center;
				background:rgba(49,108,248,1);
				border-radius: 16px 
			}
			img{
				width:40%;
				margin-left:3%;
				height:70px;
				position: relative;
				top:30px;
			}
			input:focus{
				 outline: none;
			}	
			input::-webkit-input-placeholder{
            	font-family: PingFang-SC-Regular;
				font-size: 30px;
				color: #C8C8C8;
				letter-spacing: 0.8px;
	        }
	        input::-moz-placeholder{
            	font-family: PingFang-SC-Regular;
				font-size: 30px;
				color: #C8C8C8;
				letter-spacing: 0.8px;	        	
	        }
	        input:-moz-placeholder{
            	font-family: PingFang-SC-Regular;
				font-size: 30px;
				color: #C8C8C8;
				letter-spacing: 0.8px;	        	
	        }
	        input:-ms-input-placeholder{
            	font-family: PingFang-SC-Regular;
				font-size: 30px;
				color: #C8C8C8;
				letter-spacing: 0.8px;	        	
	        }
		}	
	}
	.pro-box{
		margin-top:50px;
		ul.box-title{
			overflow: hidden;
			li{
				float:left;
				width:25%;
				text-align: center;
				line-height:100px;
			}
			li:nth-child(2){
				width:50%;
				line-height:50px;
				p{
					color:#fff;
				}
				p:first-child{
					font-size:19pt;
				}
				p:nth-child(2){
					font-size:12pt;
				}
			}
		}
		.ml-bg-register-003,.ml-bg-register-002{
			font-size:23px;
			font-family:FZLTXHK;
			color:rgba(249,255,228,1);
			p.title{
				text-align: right;
				font-size:24px;
				font-family:FZLTHJW--GB1-0;
				color:rgba(62,70,207,1);
				padding:5px 50px;
			}
			p.content{
				width:80%;
				margin:20px auto;
				text-align: justify;
			}
			ul{
				overflow: hidden;
				li{
					float:left;
					width:50%;
					text-align: center;					
					p:last-child{
						font-size:35px;
						margin-top:30px;
					}
				}
				li:first-child{
					p:last-child{
						margin-top:20px;
						font-size:59px;						
						span{
							font-size:35px;
						}						
					}
				}
			}
		}
		.ml-bg-register-004{
			font-size:23px;
			font-family:FZLTXHK;
			color:rgba(249,255,228,1);
			p.title{
				text-align: right;
				font-size:24px;
				font-family:FZLTHJW--GB1-0;
				color:rgba(62,70,207,1);
				padding:5px 50px;
			}
			p.content{
				width:80%;
				margin:40px auto;
			}
			ul{
				overflow: hidden;
				li{
					float:left;
					width:33%;
					text-align: center;					
					p:last-child{
						font-size:35px;
						margin-top:40px;
					}
				}
				li:first-child{
					p:last-child{
						margin-top:30px;
						font-size:59px;						
						span{
							font-size:35px;
						}						
					}
				}
			}
		}
	}
}	
</style>